import request from '@/utils/request'
import url from './url'

// 工单详情
export function getWoInfo(code) {
  return request({
    url: url.woGet,
    method: 'get',
    params: { code }
  })
}

// 客服工单列表
export function getWoList(params = {}) {
  return request({
    url: url.woGetPage,
    method: 'get',
    params: { current: 1, size: 100, ...params }
  })
}

// 客服工单分页
export function getWoPage(params = {}) {
  return request({
    url: url.woGetPage,
    method: 'get',
    params
  })
}
// 客户工单分页
export function getClientPage(params = {}) {
  return request({
    url: url.clientPage,
    method: 'get',
    params
  })
}

// 工单统计
export function statWo(params = {}) {
  return request({
    url: url.woStat,
    method: 'get',
    params
  })
}

// 工单添加
export function editWo(data = {}) {
  const { code} = data
  return request({
    // url: url.woAdd,
    url: code ? url.woMod : url.woAdd,
    method: 'post',
    data
  })
}

// 工单 删除
export function delWo(code) {
  return request({
    url: url.woDel,
    method: 'post',
    data: { code },
    params: { code },
  })
}

// 工单 接单
export function startWo(code) {
  return request({
    url: url.woStart,
    method: 'post',
    data: { code },
    params: { code },
  })
}
// 工单处理
export function doingWo(data = {}) {
  // code, content
  return request({
    url: url.woDoing,
    method: 'post',
    data,
    params: data,
  })
}

